﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
using System.Configuration;

namespace BHair
{
    public partial class frmgys : Form
    {
        public frmgys()
        {
            InitializeComponent();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void frmgys_Load(object sender, EventArgs e)
        {
            select();
        }
        public void select()
        {
            //编写查询所有供应商sql
            string select = "SELECT [id] as ID,[gysname] as 供应商,[gysaddress] as 地址 FROM [BHairDB].[dbo].[gys]";
            string constr = ConfigurationManager.ConnectionStrings["BHair.Properties.Settings.BHairDBConnectionString"].ConnectionString;
            SqlConnection sqlconn = new SqlConnection(constr);
            //SqlCommand comm1 = new SqlCommand(select,sqlconn);
            try
            {
                sqlconn.Open();
                DataTable dt = new DataTable();
                SqlDataAdapter sda = new SqlDataAdapter(select, sqlconn);
                sda.Fill(dt);
                this.skinDataGridView1.DataSource = dt;

            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }

        private void button1_Click(object sender, EventArgs e)
        {
            Frmgysadd gysadd = new Frmgysadd();
            gysadd.ShowDialog();
            //定义新增sql
           // string addsql = "INSERT INTO [BHairDB].[dbo].[gys]([gysID],[gysname],[gysaddress]) VALUES(01,'北京','东城')";
        }

        private void button3_Click(object sender, EventArgs e)
        {
            int id = Int32.Parse(this.skinDataGridView1.SelectedCells[0].Value.ToString());
            //MessageBox.Show('s'+id.ToString());
            chuanzhi.gysid = id;
            this.Close();
        }
    }
}
